package com.majun.web;

import com.majun.bean.User;
import com.majun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

//@CrossOrigin
//@CrossOrigin(origins = "http://127.0.0.1:8080", maxAge = 1800)
//html页面通过浏览器访问的端口63342配置http://localhost:63342可以正常访问
//@CrossOrigin(origins = "http://localhost:63342", maxAge = 1800)
@RestController
public class CorsTestController {

//    @Autowired
//    private UserService userService;

//    @CrossOrigin
//html页面通过浏览器访问的端口63342配置http://localhost:63342可以正常访问
    @CrossOrigin(origins = "http://localhost:63342", maxAge = 1800)
//    @CrossOrigin(origins = "http://127.0.0.1:8080", maxAge = 1800)
    @GetMapping(value = "/hello")
    public String hello(){
//        User result = userService.getUserById(1);
//        return result;
        String result = "Hello World";
        System.err.println("result="+result);
        return result;
    }
}
